package com.workcell.workdata.xthings.controller;

import com.workcell.workdata.common.core.util.R;
import com.workcell.workdata.common.security.annotation.Inner;
import com.workcell.workdata.xthings.dto.XthingsTvVo;
import com.workcell.workdata.xthings.service.CodeTvBoxService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;


/**
 * TV码库信息管理
 *
 * @author guogyu
 * @date 2023-05-05 09:15:50
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/codetvbox" )
@Api(value = "codetvbox", tags = "TV码库信息管理")
public class CodeTvBoxController {

    private final CodeTvBoxService codeTvBoxService;

    /**
     * 更新TV投放看板
     * @param boardVo
     * @return
     */
    @Inner
    @ApiOperation(value = "更新TV投放看板", notes = "更新TV投放看板")
    @PostMapping
    public R updatePanel(@RequestBody XthingsTvVo.BoardVo boardVo) {
        return R.ok(codeTvBoxService.updatePanel(boardVo));
    }
    /**
     * 获取TV当前投放看板
     * @param deviceNo
     * @return
     */
    @ApiOperation(value = "获取TV当前投放看板", notes = "获取TV当前投放看板")
    @GetMapping("/{deviceNo}")
    public R getByDeviceSn(@PathVariable("deviceNo") String deviceNo) {
        return R.ok(codeTvBoxService.getByDeviceNo(deviceNo));
    }

    /**
     * TV解绑租户
     * @param deviceNo
     * @return
     */
    @ApiOperation(value = "解绑租户", notes = "TV解绑租户")
    @GetMapping("/unbindTenant/{deviceNo}")
    public R unbindTenant(@PathVariable("deviceNo") String deviceNo) {
        return codeTvBoxService.unbindTenant(deviceNo);
    }
}
